package com.srd.phone.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.shengrongdai.srd.R;
import com.srd.phone.bean.UpdateVersionInfo;
import com.srd.phone.service.DownloadService;

/**
 * 更新APP界面
 */
public class DialogUpdateActivity extends AppCompatActivity implements View.OnClickListener {

    private UpdateVersionInfo info;
    private TextView alert_message;
    private Button alert_back;
    private Button alert_ok;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_activity_update);
        info = (UpdateVersionInfo) getIntent().getSerializableExtra("info");
        alert_message = (TextView) findViewById(R.id.alert_message);
        alert_back = (Button) findViewById(R.id.alert_back);
        alert_ok = (Button) findViewById(R.id.alert_ok);
        alert_message.setText(info.changelog);
        alert_back.setOnClickListener(this);
        alert_ok.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == alert_back.getId()) {
            finish();
        } else if (v.getId() == alert_ok.getId()) {
            Intent it = new Intent(this, DownloadService.class);
            it.putExtra("info", info);
            startService(it);
        }
    }
}
